package com.hbx.task.job;

import com.hbx.constant.CachePrefixContent;
import com.hbx.task.BaseJob;
import com.hbx.task.ScheduledJobEnum;
import com.hbx.utils.CacheUtils;
import com.hbx.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/*
 * @Author:hbx
 *
 * */
@Slf4j
@Component
public class CleanYesterdayMarkJob extends BaseJob {

    @Autowired
    private CacheUtils cacheUtils;

    @Override
    public ScheduledJobEnum getScheduledJobEnum() {
        return ScheduledJobEnum.REMOVE_YESTERDAY_MARK_JOB;
    }

    @Scheduled(cron = "0 0 0 * * ?")
    public void start(){
        execute();
    }

    @Override
    public Boolean beforeExecute() {
        return true;
    }

    @Override
    public void doExecute() {
        Long result = cacheUtils.removeKey(cacheUtils.keys(CachePrefixContent.REPORT_COUNT));
        log.info("{}清理举报次数限制完毕，清理{}条", DateUtil.toStringDate(new Date()), result);
    }

    @Override
    public void afterExecute() {

    }
}
